﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<title>新用户注册</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="description" content="">
	<meta name="author" content="">
	<link href="/static/css/bootstrap.min.css" rel="stylesheet" media="screen">
	<link href="/static/css/green.css" rel="stylesheet">
	<!--[if lt IE 9]>
	<script src="/static/js/html5shiv.js"></script>
	<script src="/static/js/respond.min.js"></script>
	<![endif]-->
</head>
<body>
	<div class="container">
		<!--<div class="registerBoxTop"></div>-->
		<div class="col-md-offset-3" id="registerBox">
			<form class="form-horizontal" role="form">
				<div class="form-group" id="errBox">
				</div>

				<div class="form-group" id="usernameBox">
					<label class="col-md-2 control-label">用户名</label>
					<div class="col-md-3">
						<input type="text" class="form-control" id="username" placeholder="用户名"></div>
				</div>

				<div class="form-group" id="passwordBox">
					<label class="col-md-2 control-label">密码</label>
					<div class="col-md-3">
						<input type="password" class="form-control" id="password" placeholder="密码"></div>
				</div>

				<div class="form-group">
					<div class="col-md-offset-2 col-md-10">
						<button type="button" class="btn btn-default" id="register">登录</button>
					</div>
				</div>

			</form>
		</div>

	</div>
	<script src="/static/js/jquery-1.9.0.min.js"></script>
	<script src="/static/js/bootstrap.min.js"></script>
	<script src="/static/js/jquery.md5.js"></script>
	<script src="/static/js/json2.js"></script>
	<script>
		$(document).ready(function() {

			$("#register").click(function() {
				var username = $("#username").val();
				var password = $("#password").val();
				var user = {
					Username: $.md5(username),
					Password: $.md5(password)
				}
				var jsonList = JSON.stringify(user);

				$("label").remove(".errlabel");

				$.ajax({
					type: "post",
					contentType: "application/json; charset=utf-8",
					dataType: "json",
					url: "/green/user/login",
					data: jsonList,
					//async : false,
					success: function(data) {
						$.each(data, function(k, v) {
							if (v.Key=="uperr"){
								$("#errBox").append("<label class=\"errlabel control-label\"><b class=\"text-danger pull-left\">" + v.Message + "</b></label>");
							}else if (v.Key=="loginSuccess"){
								location.href="/green";
							}
						});
					}
				});
			});
		});
</script>
</body>
</html>